<% content_for :left_sidebar do  %>
  <%= render :partial => "layouts/sidebar/xiwenguanli" %>
<% end %>
<div class="page-header">
  <h1>微博稿件列表</h1>
</div>

<%= form_tag admins_weibos_path,:method => :get do %>
    <table class="search_table">
      <tr>
        <td>稿件类型:
        	<% if (current_user.admin? )  %>
	          <%= select_tag :weibo_type,options_for_select([['我的稿件',1],['平台稿件',2]],params[:weibo_type])%>
	          <% else %>
	          <%= select_tag :weibo_type,options_for_select([['我的稿件',1]],params[:weibo_type])%>
	         <% end %>
        </td>
        <td>稿件状态:
          <%= select_tag :check,options_for_select([['--请选择--',nil]] + Weibo::CHECK.to_a,params[:check]) %>
        </td>
      </tr>
      <tr>
        <td colspan="6">
          <%= select_button %>
          <%= new_button url: new_admins_weibo_path %>
        </td>
      </tr>
    </table>
<% end %>

<table class="table table-striped">
  <thead>
    <tr>
      <th>ID</th>
      <th>短微博</th>
      <th>发稿人</th>
      <th>状态</th>
      <th>操作</th>
    </tr>
  </thead>
  <tbody>
    <% @weibos.each do |weibo| %>
      <tr>
        <td><%=  weibo.id %></td>
        <td><%=link_to truncate(weibo.content,:length => 30), admins_weibo_path(weibo) %></td>
        <td><%= weibo.postby %></td>
        <td>
          <% if weibo.check == 0 %>
              <%= weibo.check_text %>
          <% else  %>
              <%= link_to "#{weibo.check_text}",admins_weibo_path(weibo) %>
          <% end %>
        </td>
        <td>
          <% if Weibo.can_edit?(weibo,@current_user) %>
              <%= link_to "编辑",edit_admins_weibo_path(weibo),:class => 'btn btn-default btn-xs' %>
              <%= link_to "删除",admins_weibo_path(weibo),
                          :method => :delete,
                          :data => { :confirm => '确定删除?' },
                          :class => 'btn btn-xs btn-danger' %>
          <% end %>
          <% if Weibo.can_approve?(weibo,@current_user) %>
              <%= link_to "审核",admins_weibo_path(weibo),:class => 'btn btn-info btn-xs' %>
          <% end %>
          <% if weibo.check == 0 %>
              <%= link_to "送审",admins_weibo_path(weibo),:class => 'btn btn-info btn-xs' %>
          <% end %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>
<div class="count">
  <%= paginate @weibos %>
</div>